#include <stdio.h>
#include <stdlib.h>

int un_g_val;
int g_val = 100;

int main()
{
    printf("code addr: %p\n\n", main); // 代码区地址
    const char* str = "hello";
    printf("read only string addr: %p\n\n", str); // 字符常量区地址
    printf("init global value addr: %p\n\n", &g_val); // 已初始化全局数据区
    printf("uninit global value addr: %p\n\n", &un_g_val); // 未初始化全局数据区
    
    char* p1 = (char*)malloc(16);
    char* p2 = (char*)malloc(16);
    char* p3 = (char*)malloc(16);
    
    printf("heap addr: %p\n", p1); // 堆地址
    printf("heap addr: %p\n", p2);
    printf("heap addr: %p\n\n", p3);
    printf("stack addr: %p\n", &str); // 栈地址
    printf("stack addr: %p\n", &p1);
    printf("stack addr: %p\n", &p2);
    printf("stack addr: %p\n\n", &p3);
    
    static int a = 0;
    printf("static addr: %p\n", &a); // static变量的地址

    return 0;
}


